#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''

本代码仅限应用于Microsoft Windows系列系统

'''
import os
import time
doscls = os.system("cls")
listpath = input('请输入目标文件夹(请以\"\\"结尾):')
files = os.listdir(listpath)
old_por = input('请输入欲修改后缀(不含\".\"):')
new_por = input('请输入欲改成后缀(不含\".\"):')
for old_name in files:
    portion = os.path.splitext(old_name)
    #print(listpath + old_name,'的后缀是:',portion[1])
    if portion[1] == "." + old_por:
        new_name = listpath + portion[0] + "." + new_por
        file_name = listpath + old_name
        os.rename(file_name, new_name)
        print("文件 ", file_name, " 的格式已更改为 ", portion[0] + "." + new_por)
        time.sleep(0.1)
# doscls=os.system("cls")
'''
def printer(text,delay=0.1):
	"""打字机效果"""
	for ch in text:
		print(ch,end = ' ', flush=True)
		time.sleep(delay)
printer("请稍等,其实文件名称早就改完了,我只不过在这里跑一下效果\n你现在就可以关掉这个窗口了,下面的效果真心没有什么大用,我就是想秀一下")
print('')
files=os.listdir(listpath)
for old_name in files:
	portion=os.path.splitext(old_name)
	if portion[1] == "." + new_por:
		file_name=listpath + old_name
	print("文件 " +file_name + " 已更改完成")
	time.sleep(0.1)
'''
